package com.xywh.micro_warehousing.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.base.BaseConstants;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.xywh.micro_warehousing.R;
import com.xywh.micro_warehousing.di.component.DaggerUnlockedSuccessfullyComponent;
import com.xywh.micro_warehousing.di.module.UnlockedSuccessfullyModule;
import com.xywh.micro_warehousing.mvp.contract.UnlockedSuccessfullyContract;
import com.xywh.micro_warehousing.mvp.presenter.UnlockedSuccessfullyPresenter;
import com.xywh.micro_warehousing.mvp.ui.entity.UnlockedSuccessfully;

import org.simple.eventbus.EventBus;

import java.util.HashMap;

import butterknife.OnClick;
import me.jessyan.armscomponent.commonres.utils.ToolbarUtils;
import me.jessyan.armscomponent.commonsdk.core.RouterHub;

import static com.jess.arms.base.BaseConstants.MAIN_CURRENT_ONE;
import static com.jess.arms.base.BaseConstants.MAIN_CURRENT_THREE;
import static com.jess.arms.utils.Preconditions.checkNotNull;


@Route(path = RouterHub.ACTIVITY_UNLOCKED_SUCCESSFULLY)
public class UnlockedSuccessfullyActivity extends BaseActivity<UnlockedSuccessfullyPresenter> implements UnlockedSuccessfullyContract.View {


    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerUnlockedSuccessfullyComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .unlockedSuccessfullyModule(new UnlockedSuccessfullyModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_unlocked_successfully; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

        ToolbarUtils.initToolbarTitleBack(this, getString(R.string.activity_unlocked_successfully));
//        getUnlockedSuccessfullyData();
    }

    private void getUnlockedSuccessfullyData() {
        HashMap<String, String> map = new HashMap<>();

        mPresenter.getUnlockedSuccessfullyData(map);
    }

    @Override
    public void getUnlockedSuccessfullyDataSuccess(UnlockedSuccessfully entityData) {


    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }


    @OnClick(R.id.btn_back)
    public void onViewClicked() {
        killMyself();
    }

    @OnClick(R.id.tv_declare)
    public void baoXiu() {
        EventBus.getDefault().post(MAIN_CURRENT_THREE, BaseConstants.SET_CURRENT_ITEM);
        killMyself();
    }
}
